package com.aspose.cells;

import java.util.ArrayList;

class zbcb extends zbz {
   ArrayList a;

   zbcb(Scenario var1) {
      this.c(175);
      byte var2 = 7;
      byte[] var3 = zco.a(var1.b);
      int var14 = var2 + var1.b.length() + 1;
      byte[] var4 = null;
      if (var1.getUser() != null && !"".equals(var1.getUser())) {
         var4 = zco.a(var1.getUser());
         var14 += var1.getUser().length() + 3;
      }

      byte[] var5 = null;
      if (var1.getComment() != null && !"".equals(var1.getComment())) {
         var5 = zco.a(var1.getComment());
         var14 += var1.getComment().length() + 3;
      }

      int var6 = var1.getInputCells().getCount();
      var14 += 6 * var6;

      int var7;
      for(var7 = 0; var7 < var6; ++var7) {
         ScenarioInputCell var8 = var1.getInputCells().get(var7);
         var14 += var8.c.length() + 3;
         if (!zakq.f(var8.c)) {
            var14 += var8.c.length();
         }
      }

      if (var14 > 8224) {
         this.a((short)8224);
         this.c = new byte[8224];
      } else {
         this.a((short)var14);
         this.c = new byte[this.d()];
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, this.c, 0, 2);
      this.c[2] = (byte)(var1.isLocked() ? 1 : 0);
      this.c[3] = (byte)(var1.isHidden() ? 1 : 0);
      this.c[4] = (byte)var1.b.length();
      this.c[5] = (byte)(var1.getComment() != null ? var1.getComment().length() : 0);
      this.c[6] = (byte)(var1.getUser() != null ? var1.getUser().length() : 0);
      byte var15 = 7;
      this.c[var15] = (byte)(var3.length == var1.b.length() ? 0 : 1);
      System.arraycopy(var3, 0, this.c, var15 + 1, var3.length);
      var7 = var15 + var3.length + 1;
      if (var4 != null) {
         zco.a(this.c, var7, var4, var1.getUser());
         var7 += 3 + var4.length;
      }

      if (var5 != null) {
         zco.a(this.c, var7, var5, var1.getComment());
         var7 += 3 + var5.length;
      }

      for(int var16 = 0; var16 < var6; ++var16) {
         ScenarioInputCell var9 = var1.getInputCells().get(var16);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var9.a), 0, this.c, var7, 2);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var9.b), 0, this.c, var7 + 2, 2);
         var7 += 4;
      }

      byte[] var17 = this.c;

      int var18;
      for(var18 = 0; var18 < var6; ++var18) {
         ScenarioInputCell var10 = var1.getInputCells().get(var18);
         byte[] var11 = zco.a(var10.c);
         int var12 = 3 + (var11 == null ? 0 : var11.length);
         if (var7 + var12 > var17.length) {
            var14 -= var7;
            if (var17 == this.c) {
               this.a((short)var7);
               if (var14 > 8224) {
                  var17 = new byte[8224];
               } else {
                  var17 = new byte[var14];
               }
            } else {
               zmo var13 = new zmo();
               var13.a(var17, 0, var7);
               if (this.a == null) {
                  this.a = new ArrayList();
               }

               com.aspose.cells.b.a.a.ze.a(this.a, (Object)var13);
            }

            var7 = 0;
         }

         zco.a(var17, var7, var11, var10.c);
         var7 += var12;
      }

      if (var7 + var6 * 2 > var17.length) {
         var18 = var6 * 2 - (var17.length - var7);
         if (var17 == this.c) {
            this.a((short)8224);
            var17 = new byte[var18];
         } else {
            zmo var19 = new zmo();
            var19.b(var17);
            if (this.a == null) {
               this.a = new ArrayList();
            }

            com.aspose.cells.b.a.a.ze.a(this.a, (Object)var19);
            var17 = new byte[var18];
            var7 = var18;
         }
      } else {
         var7 += var6 * 2;
      }

      if (this.c != var17) {
         zmo var20 = new zmo();
         var20.a(var17, 0, var7);
         if (this.a == null) {
            this.a = new ArrayList();
         }

         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var20);
      }

   }

   void a(zqa var1) throws Exception {
      byte[] var2 = new byte[4];
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.f()), 0, var2, 0, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.d()), 0, var2, 2, 2);
      var1.a(var2);
      if (this.c != null && this.c.length != 0) {
         var1.a(this.c);
      }

      if (this.a != null) {
         for(int var3 = 0; var3 < this.a.size(); ++var3) {
            zmo var4 = (zmo)this.a.get(var3);
            var4.a(var1);
         }
      }

   }
}
